import * as types from '../constants/ActionTypes';

const initState = {
    market_status : 0, 
    message : '加载中', 
    results : []
};

export default function market(state = initState, action = {}) {
    const {
        type, payload
    } = action;

    switch (type) {
    	case types.FETCH_MARKET:
    		return { ...payload };
        case types.FETCH_MARKET_SUCCESS:

            let successData = {
                market_status : 1,
                message :"获取行情列表成功",
                results : payload.results
            };
            return successData;

        case types.FETCH_MARKET_FAILURE:
            let failureData = {
                market_status : -1,
                message :"获取行情列表失败",
                results : []
            };
            return failureData;
        default:
            return state;
    }
}